/**
 * 函数柯里化
 */
function curry(fn) {
    var Slice = [].slice;
    var args = Slice.call(arguments, 1);
    console.log(888, args);
    return function() {
        var addArgs = Slice.call(arguments),
            allArgs = args.concat(addArgs);
        console.log(999, allArgs, addArgs);
        return fn.apply(null, allArgs);
    }
}

//用柯里化器添加一个加法器
function add(num1, num2) {
    return num1 + num2;
}

function add5(num) {
    return add(5, num);
}

console.log(add(1, 2));
console.log(add5(6));

var add5 = curry(add, 5);
console.log(add5(7));

var add7and8 = curry(add, 7, 8);
console.log(add7and8());
